﻿@{
    ViewBag.Title = "Edit";
    Layout = "../Shared/_Layout.cshtml";
}
@using mscook.mvc;
@model mscook.mvc.Areas.weblogin.Models.ChefModel

@section JavaScript
{
    <script type="text/javascript" src="@Url.Content("~/scripts/jquery.validate.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/scripts/jquery.validate.unobtrusive.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/scripts/jquery.unobtrusive-ajax.js")"></script>
}
@Html.Partial("_BtnModalLoder")
@Html.Partial("_MultiBtnModalLoder")
<div id="resourceTypeModal" class=" modal hide fade form-horizontal">
</div>
<div id="hotelModal" class=" modal hide fade form-horizontal">
</div>
<div class="row-fluid sortable">
    <div class="box span12">
        <div class="box-header well">
            <h2><i class="icon-edit"></i>Form Elements</h2>
            <div class="box-icon">
                <a href="@Url.Action("Add")" class="btn btn-setting btn-round"><i class="icon-plus-sign"></i></a>
            </div>
        </div>
        <div class="box-content">
            @using (Html.BeginForm("Edit", "chef", FormMethod.Post, new { @class = "form-horizontal", enctype = "multipart/form-data" }))
            {
                
             
              
                <fieldset>
                    <legend>厨师编辑</legend>
                    @Html.ValidationSummary(true);
                    <input type="hidden" name="Id" value="@Model.Chef.Id" />
                    <div class="control-group">
                        <label class="control-label">厨师名</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @Html.TextBoxFor(chef => Model.Chef.Name, new { size = "16" })
                            </div>
                            @Html.ValidationMessageFor(model => model.Chef.Name)
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">职位</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @Html.TextBoxFor(chef => Model.Chef.Position, new { size = "16" })
                            </div>
                            @Html.ValidationMessageFor(model => model.Chef.Position)
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">地区</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @Html.TextBoxFor(chef => Model.Chef.Address, new { size = "16" })
                            </div>
                            @Html.ValidationMessageFor(model => model.Chef.Address)
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">编辑</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @Html.TextBoxFor(chef => Model.Chef.Editor, new { size = "16" })
                            </div>
                            @Html.ValidationMessageFor(model => model.Chef.Editor)
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">置顶</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @{
                bool isTop = Model.Chef.EntityIndex != 0;
                                    <select id="IsTop" name="IsTop">
                                        @if (isTop)
                                        {
                                            <option value="false">否</option>                                   
                                            <option value="true" selected="selected">是</option>
                                        }
                                        else
                                        {
                                            <option value="false" selected="selected">否</option>
                                            <option value="true">是</option>
                                        }
                                    </select>
                                }
                            </div>

                        </div>
                    </div>



                    <div class="control-group">
                        <label class="control-label">简介</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @Html.TextAreaFor(chef => Model.Chef.Summary, new { rows = "10", size = "16", @class = "cleditor" })
                            </div>
                            @Html.ValidationMessageFor(model => model.Chef.Summary)
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">类型</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @{
                                        var names = "";
                                        var ids = "";
                                        int count = Model.ResourceTypes.Count;
                                        for (int i = 0; i < count; i++)
                                        {
                                            var item = Model.ResourceTypes.ElementAt(i);
                                            names += item.Name;
                                            ids += item.Id;

                                            if (count - 1 != i)
                                            {
                                                names += ",";
                                                ids += ",";
                                            }
                                        }
                                    
                                    @Html.TextBox("ChefTypeName", names, new { @readonly = "true" })
                                    @Html.Hidden("ChefTypeId", ids)
                                }

                            </div>
                            <button id="resourceTypeModalBtn" type="button" class="btn btn-primary multimodalLoder" data-num="1" data-link-name="ChefTypeName" data-link-id="ChefTypeId" data-link-modal="resourceTypeModal" data-type="Chef" data-url="/weblogin/resourcetype/MultiResourceTypeModal"><i class="icon-edit icon-white"></i></button>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">酒店</label>
                        <div class="controls">
                            <div class="input-prepend">
                                @{
                                        bool isNull = Model.Chef.Hotel == null;
                                    <input type="hidden" id="HotelId" name="HotelId" value="@Html.Encode(isNull ? "" : Model.Chef.Hotel.Id)" />
                                    <input readonly="true" type="text" id="HotelName" name="HotelName" value="@Html.Encode(isNull ? "" : Model.Chef.Hotel.Name)" />
                                }


                            </div>
                            <button type="button" id="HotelModalBtn" class="btn btn-primary modalLoder" data-num="1" data-link-name="HotelName" data-link-id="HotelId" data-link-modal="hotelModal" data-url="/weblogin/hotel/hotelModal"><i class="icon-edit icon-white"></i></button>

                        </div>
                    </div>



                    <div class="control-group">
                        <label class="control-label">图片</label>
                        <div class="controls">
                            <div class="input-prepend" style="width: 400px">
                                <!--<img src="~/Upload/default/@Model.Chef.ImageName"/>-->
                                @if (string.IsNullOrEmpty(Model.Chef.ImageName))
                                {
                                    <img id="preview" style="display: none; width: 100%" />
                                }
                                else
                                {
                                    <img id="preview"  style="width:100%" src="~/Upload/@Model.Chef.ImageName"  />
                                }
                            </div>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">图片上传</label>
                        <div class="controls">

                            <div class="fileupload @(string.IsNullOrEmpty(Model.Chef.ImageName) ? "fileupload-new" : "fileupload-exists")" data-provides="fileupload">
                                <span class="btn btn-file">
                                    <span class="fileupload-new">请选择图片</span>
                                    <span class="fileupload-exists">更改图片</span>
                                    <input name="related_content_image[0]" type="file" />
                                </span>
                                <span class="fileupload-preview">@Model.Chef.ImageName</span>
                                <input name="existed_related_content_image[0]" value="@Model.Chef.ImageName" type="hidden" />
                                <a href="#" class="close fileupload-exists" data-dismiss="fileupload" style="float: none">×</a>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </fieldset>
                
            }
        </div>
    </div>
    <!--/span-->

</div>
